﻿<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
class SCTV_InformationRequestInstall extends ModuleInstall {
    public function install() {		  
		Base_ThemeCommon::install_default_theme($this->get_type());
	
		$fields = array(
			array('name'=>_M('Requirement'), 'type'=>'select', 'param'=>array('SCTV_Requirement'=>'Requirement Code'), 'required'=>true, 'visible'=>true),
			array('name'=>_M('Information Group'), 'type'=>'select', 'param'=>array('SCTV_InformationGroup'=>'Name'), 'required'=>true, 'visible'=>true),
			array('name'=>_M('Information'), 'type'=>'select', 'param'=>array('SCTV_Information'=>'Name'), 'required'=>true, 'visible'=>true, 'display_callback'=>array('SCTV_InformationRequestCommon', 'display_information'), 'QFfield_callback'=>array('SCTV_InformationRequestCommon', 'QFfield_information')),
			array('name'=>_M('Status'), 'type'=>'checkbox', 'required'=>true, 'visible'=>true, 'extra'=>true, 'display_callback'=>array('SCTV_InformationRequestCommon', 'display_status'), 'QFfield_callback'=>array('SCTV_InformationRequestCommon', 'QFfield_status')),
			array('name'=>_M('Note'), 'type'=>'long text', 'required'=>false, 'visible'=>true)
		);		
		Utils_RecordBrowserCommon::install_new_recordset('SCTV_InformationRequest', $fields);		
		Utils_RecordBrowserCommon::set_caption('SCTV_InformationRequest', _M('Information Request'));
		Utils_RecordBrowserCommon::add_default_access('SCTV_InformationRequest');
		
		$fields = array(
			array('name'=>_M('Name'), 'type'=>'text', 'param'=>32, 'required'=>true, 'visible'=>true)
		);		
		Utils_RecordBrowserCommon::install_new_recordset('SCTV_InformationGroup', $fields);		
		Utils_RecordBrowserCommon::set_caption('SCTV_InformationGroup', _M('Information Group'));
		Utils_RecordBrowserCommon::add_default_access('SCTV_InformationGroup');
		
		$fields = array(			
			array('name'=>_M('Name'), 'type'=>'text', 'param'=>32, 'required'=>true, 'visible'=>true),
			array('name'=>_M('Information Group'), 'type'=>'select', 'param'=>array('SCTV_InformationGroup'=>'Name'), 'required'=>true, 'visible'=>true),
		);		
		Utils_RecordBrowserCommon::install_new_recordset('SCTV_Information', $fields);		
		Utils_RecordBrowserCommon::set_caption('SCTV_Information', _M('Information'));
		Utils_RecordBrowserCommon::add_default_access('SCTV_Information');
		
		Utils_RecordBrowserCommon::new_addon('SCTV_Requirement', 'SCTV_InformationRequest', 'requirement_addon', _M('Information Request'));
		
		Utils_CommonDataCommon::new_array('SCTV/RequestStatus',array(_M('Open'),_M('Resolved'),_M('Reject'), _M('Closed')), true,true);
        return true;
    }
 
    public function uninstall() {
		Base_ThemeCommon::uninstall_default_theme($this->get_type());
		Utils_RecordBrowserCommon::uninstall_recordset('SCTV_InformationRequest');
		Utils_RecordBrowserCommon::uninstall_recordset('SCTV_InformationGroup');
		Utils_RecordBrowserCommon::uninstall_recordset('SCTV_Information');
		
		Utils_CommonDataCommon::remove('SCTV/RequestStatus');
		return true;		
    }
 
    public function info() {
        return array(
        	'Author'=>'Pham Huu Le Quoc Phuc',
            'License'=>'SCTV',
            'Description'=>'InformationRequest');
    }
 
    public function simple_setup() { 
        return array('package' => __('InformationRequest'), 'version'=>'1.0');
    }
 
    public function requires($v) {
        return array();
    }
 
    public function version() {
        return array('1.0');
    }
}
 
?>